/**
 * 进度查看scheduleList.js
 * 版本号： v1.0.0
 */
$(function(){
    var purId = $('#purId_').val();
    $("#detail_dataList").datagrid({
        fit:true,
        method: "POST",
        rownumbers: true,
        singleSelect:true,
        pagination: true,
        striped: true,
        border: false,
        pageSize:20,
        pageList:[20,50,100],
        url: CONTEXT_PATH + '/purchaseApplyCheck/getContrastList.do?purId='+purId,
        idField: 'purId',
        columns: [
            [
                {field: 'materialName', title: '材料名称', width: 150, fixed: true,align:'center'},
                {field: 'standardType', title: '规格型号', width: 150, fixed: true,align:'center'},
                {field: 'purdNum', title: '本次请购量', width: 80, fixed: true,align:'center'},
                {field: 'unitPrice', title: '单价', width: 70, fixed: true,align:'center'},
                {field: 'leftCount', title: '合同剩余量', width: 80, fixed: true,align:'center'},
                /* {field: 'explain', title: '需求说明', width: 140, fixed: true,align:'center'},
                 {field: 'belongSystem', title: '所属系统', width: 120, fixed: true,align:'center'},*/
                {field: 'meteringUnit', title: '计量单位', width: 70, fixed: true,align:'center'},
                {field: 'purdRemark', title: '备注', width: 200,align:'center',editor:'textbox'},
            ]
        ]
    });
    //定义可操作按钮
    $("#detail_Menu").dialog({
        title: '',
        width: 'auto',
        height:35,
        closed: false,
        cache: false,
        inline: true,
        modal: false,
        border: false,
        toolbar: createToolbar()
    });
});




/**
 * 创建toolbar按钮组
 * @returns {Array}
 */
function createToolbar() {
    var toolbar = [];
    var falg = false;
    for (var j = 0; j < btnOptions.length; j++) {
        if (false != btnOptions[j].value) {
            falg = true;
            break;
        }
    }
    if (!falg) {
        //不存在按钮
        toolbar.push({});
    } else {
        //存在按钮
        for (var i = 0; i < btnOptions.length; i++) {
            if (false != btnOptions[i].value) {
                //查询
                if ("searchBtn" == btnOptions[i].key) {
                    toolbar.push({
                        id:btnOptions[i].value.meId,
                        text:btnOptions[i].value.name,
                        iconCls:btnOptions[i].value.iconCls,
                        handler: function () {
                           search();
                        }
                    });
                }
                //返回
                if ("cancelBtn" == btnOptions[i].key) {
                    toolbar.push({
                        id:btnOptions[i].value.meId,
                        text:btnOptions[i].value.name,
                        iconCls:btnOptions[i].value.iconCls,
                        handler: function () {
                            window.location.href = CONTEXT_PATH + "/purchaseSchedule/index.do"
                        }
                    });
                }
            }
        }
        return toolbar;
    }
}

/**
 * 查询
 */
function search() {
    //刷新页码
    refreshPageNumber("detail_dataList");
    $("#detail_dataList").datagrid("reload", {
        //查询数据
        materialName: $("#materialName").textbox('getValue')
    });
    $("#detail_dataList").datagrid("clearSelections");
}